/** 删除最后一位并返回该元素 */
const arr = [1, 2, 3];
console.log(arr.pop());
console.log(arr);

function myPop() {
  const res = this[this.length - 1];
  this[this.length - 1] = undefined;
  this.length -= 1;
  return res;
}

Array.prototype.myPop = myPop;

const arr2 = [1, 2, 3];
console.log(arr2.myPop());
console.log(arr2);
